import Vue from 'vue'
import Router from 'vue-router'
import {Layout, Content} from '../layout' // 页面整体布局
Vue.use(Router)
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
};
//默认不需要权限的页面
export const constantRouterMap = [
  {
    path: '',
    component: Layout,
    redirect: '/index/index',
    hidden: true
  },
  { path: '/login', component: () => import('@/page/login')},
  {
    path: '/index',
    component: Layout,
    name: 'index',
    meta: {
      title: '总览'
    },
    noDropdown:true,
    children: [
      {
        path: 'index',
        meta: {
          title: '总览'
        },
        component: () => import('@/page/index/index'),
      }
    ]
  },
  {
    path:'/electricBoxManage',
    name: 'electricBoxManage',
    component: Layout,
    meta: {
      title:'电盒管理'
    },
    noDropdown: false,
    children:[
      {
        path:'deviceManage', 
        name: 'deviceManage',
        meta:{
          title:'设备管理'
        },
        component: () => import('@/page/electricBoxManage/deviceManage'),
        children: [
          {
            path: 'deviceDetail',
            name: 'deviceDetail',
            meta:{
              title:'设备详情'
            },
            component: () => import('@/page/electricBoxManage/deviceInfo'),
          },
        ]
      },
      {
        path:'deviceGroup', 
        name: 'deviceGroup',
        meta:{
          title:'设备分组'
        },
        component: () => import('@/page/electricBoxManage/deviceGroup'),
        children: [
          {
            path: 'groupDetail',
            name: 'groupDetail',
            meta:{
              title:'分组详情'
            },
            component: () => import('@/components/electric/groupDetail'),
          }
        ]
      },
      {
        path:'alarmManage', 
        name: 'alarmManage',
        meta:{
          title:'告警管理'
        },
        component: () => import('@/page/electricBoxManage/alarmManage'),
        children: [
          {
            path: 'alarmRule',
            name: 'alarmRule',
            meta:{
              title:'告警规则'
            },
            component: () => import('@/components/electric/alarmRule'),
          }
        ]
      },
      {
        path:'strategyManage', 
        name: 'strategyManage',
        meta:{
          title:'策略管理'
        },
        component: () => import('@/page/electricBoxManage/strategyManage'),
        children: [
          {
            path: 'addstragey',
            name: 'addstragey',
            meta:{
              title:'添加策略'
            },
            component: () => import('@/components/electric/addStragey'),
          },
          {
            path: 'updatestragey',
            name: 'updatestragey',
            meta:{
              title:'修改策略'
            },
            component: () => import('@/components/electric/addStragey'),
          },
          {
            path: 'viewstragey',
            name: 'viewstragey',
            meta:{
              title:'查看策略'
            },
            component: () => import('@/components/electric/viewStragey'),
          },
        ]
      }
    ]
  },
  {
    path:'/networkBoxManage',
    name: 'networkBoxManage',
    component: Layout,
    meta: {
      title:'网盒管理'
    },
    noDropdown: false,
    children:[
      {
        path:'deviceManage', 
        name: 'deviceManage',
        meta:{
          title:'设备管理'
        },
        component: () => import('@/page/networkBoxManage/deviceManage'),
        children: [
          {
            path: 'deviceDetail',
            name: 'deviceDetail',
            meta:{
              title:'设备详情'
            },
            component: () => import('@/page/electricBoxManage/deviceInfo'),
          },
        ]
      },
      {
        path:'deviceGroup', 
        name: 'deviceGroup',
        meta:{
          title:'设备分组'
        },
        component: () => import('@/page/networkBoxManage/deviceGroup'),
      },
      {
        path:'vlanManage', 
        name: 'vlanManage',
        meta:{
          title:'Vlan管理'
        },
        component: () => import('@/page/networkBoxManage/vlanManage'),
      },
      {
        path:'alarmManage', 
        name: 'alarmManage',
        meta:{
          title:'告警管理'
        },
        component: () => import('@/page/networkBoxManage/alarmManage'),
      },
      {
        path:'strategyManage', 
        name: 'strategyManage',
        meta:{
          title:'策略管理'
        },
        component: () => import('@/page/networkBoxManage/strategyManage'),
      }
    ]
  },
  {
    path:'/sensorManage',
    name: 'sensorManage',
    component: Layout,
    meta: {
      title:'传感器管理'
    },
    noDropdown: true,
    children: [
      {
        path: 'sensorManage',
        meta: {
          title: '传感器管理'
        },
        component: () => import('@/page/sensorManage/sensorManage'),
      }
    ]
  },
  {
    path:'/accountManage',
    name: 'accountManage',
    component: Layout,
    meta: {
      title:'账户管理'
    },
    noDropdown: false,
    children: [
      {
        path: 'role',
        name:'role',
        meta:{
          title:'角色管理'
        },
        component: () => import('@/page/accountManage/role'),
      },
      {
        path: 'merchant',
        name:'merchant',
        meta:{
          title:'商户管理'
        },
        component: () => import('@/page/accountManage/merchant'),
      },
      {
        path: 'account',
        name:'account',
        meta:{
          title:'账号管理'
        },
        component: () => import('@/page/accountManage/account'),
      }
    ]
  },
  {
    path:'/sysSetting',
    name: 'sysSetting',
    component: Layout,
    meta: {
      title:'系统设置'
    },
    noDropdown: false,
    children: [
      {
        path: 'log',
        name:'log',
        meta:{
          title:'系统日志'
        },
        component: () => import('@/page/sysSetting/log'),
      },
      {
        path: 'sntp',
        name:'sntp',
        meta:{
          title:'SNTP设置'
        },
        component: () => import('@/page/sysSetting/sntp'),
      },
      {
        path: 'synch',
        name:'synch',
        meta:{
          title:'电盒同步同期设置'
        },
        component: () => import('@/page/sysSetting/synch'),
      },
      {
        path: 'auth',
        name:'auth',
        meta:{
          title:'认证管理'
        },
        component: () => import('@/page/sysSetting/auth'),
      }
    ]
  }
] 

//注册路由
export default new Router({
	routes: constantRouterMap
})